package com.mywork.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mywork.dao.RecipeMapper;
import com.mywork.dao.RefundMapper;
import com.mywork.dao.RefundViewMapper;
import com.mywork.po.Page;
import com.mywork.po.Refund;
import com.mywork.po.RefundView;

@Service
public class RefundService {

	@Autowired
	RefundMapper refundDao;
	
	@Autowired
	RecipeMapper recipeMapper;
	
	@Autowired
	RefundViewMapper refundViewDao;
	//为处方退费，修改处方isRun字段为3表示退费成功，为refund表添加记录
	public void refund(Refund refund, String userid) {
		// TODO 自动生成的方法存根
		recipeMapper.changeIsRun(refund.getRecipeid());
		refund.setTime(new Date());
		refund.setUserid(userid);
		refundDao.insert(refund);
	}
	public List<RefundView> getAllRefundList(Page page) {
		// TODO 自动生成的方法存根
		return refundViewDao.getAllRefundList(page.getPageSize()*page.getPageNo(),page.getPageSize());
	}
	public int getCountOfAllRefund() {
		// TODO 自动生成的方法存根
		return refundViewDao.getCountOfAllRefund();
	}

}
